const mysql = require('mysql')

const pool = mysql.createPool({
  host: 'localhost',
  port: '3306',
  user: 'root',
  database: '1808A-blogs',
  password: '3052959wyp.'
})

const exec = (sql, params) => {
  return new Promise((resolve, reject) => {
    pool.query(sql, params, (err, data) => {
      if(err) {
        reject(err)
      } else {
        resolve(data)
      }
    })
  })
}

module.exports = {
  exec
}